package com.tbsoft.ehr.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 * 银行账户信息
 * 
 * @author lizhenhua
 * 
 */
@Entity
@Table(name = "EHR_ACCOUNT")
public class Account {

	private String accountId;
	private String bankName;

	public Account() {
	}

	public Account(String accountId, String bankName) {
		this.accountId = accountId;
		this.bankName = bankName;
	}

	@Id
	@Column(name = "ACCOUNT_ID", nullable = false, length = 50)
	public String getAccountId() {
		return accountId;
	}

	public void setAccountId(String accountId) {
		this.accountId = accountId;
	}

	@Column(name = "BANK_NAME", nullable = false, length = 50)
	public String getBankName() {
		return bankName;
	}

	public void setBankName(String bankName) {
		this.bankName = bankName;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((accountId == null) ? 0 : accountId.hashCode());
		result = prime * result
				+ ((bankName == null) ? 0 : bankName.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Account other = (Account) obj;
		if (accountId == null) {
			if (other.accountId != null)
				return false;
		} else if (!accountId.equals(other.accountId))
			return false;
		if (bankName == null) {
			if (other.bankName != null)
				return false;
		} else if (!bankName.equals(other.bankName))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "开户银行：" + this.getBankName() + ",银行账号:" + this.getAccountId();
	}

	public boolean notNull() {
		if (this.accountId != null && this.accountId.length() > 0
				&& this.bankName != null && this.bankName.length() > 0) {
			return true;
		}
		return false;
	}

}
